// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   Scale.java

package com.java4less.rchart;


public class Scale
{

	public boolean exactMaxValue;
	public boolean exactMinValue;
	public double preferred_MaxMin_values[] = {
		-1000000D, -500000D, -100000D, -50000D, -10000D, -5000D, -1000D, -500D, -250D, -100D, 
		-50D, -35D, -5D, -1D, -0.5D, -0.10000000000000001D, 0.0D, 0.10000000000000001D, 0.5D, 1.0D, 
		5D, 10D, 25D, 50D, 100D, 250D, 500D, 1000D, 5000D, 10000D, 
		50000D, 100000D, 500000D, 1000000D
	};
	public double max;
	public double min;
	public int screenMax;
	public int screenMaxMargin;
	public int screenMin;
	public boolean reverse;

	public Scale()
	{
		exactMaxValue = false;
		exactMinValue = false;
		max = -99999D;
		min = 99999D;
		reverse = false;
	}

	public Scale(int ma, int mi)
	{
		exactMaxValue = false;
		exactMinValue = false;
		max = -99999D;
		min = 99999D;
		reverse = false;
		max = ma;
		min = mi;
	}

	public int getScreenCoord(double v)
	{
		double range = max - min;
		if (min < 0.0D && max < 0.0D)
			range = (min - max) * -1D;
		int i = screenMaxMargin - screenMin;
		i = (int)(((v - min) * (double)i) / range);
		if (!reverse)
			i += screenMin;
		else
			i = (screenMax - screenMin - i) + screenMin;
		return i;
	}

	public double getValue(int c)
	{
		if (!reverse)
			c -= screenMin;
		else
			c = screenMax - c;
		double range = max - min;
		if (min < 0.0D && max < 0.0D)
			range = (min - max) * -1D;
		double i = screenMaxMargin - screenMin;
		i = ((double)c * range) / i;
		i += min;
		return i;
	}
}
